Skip to content

feat: update insightsProject slug (CM-1043)#3923

Merged
ulemons merged 3 commits intomainfrom
feat/update-insights-slug
Mar 18, 2026
Merged

feat: update insightsProject slug (CM-1043)#3923
ulemons merged 3 commits intomainfrom
feat/update-insights-slug

Conversation

@ulemons
Copy link
Contributor

@ulemons ulemons commented Mar 16, 2026

Summary

  • When a sub-project (leaf segment) slug is updated in CDP, the corresponding insightsProjects.slug is now automatically synced.
  • The three securityInsights* tables (securityInsightsEvaluationAssessments, securityInsightsEvaluationSuites,
    securityInsightsEvaluations) get their insightsProjectSlug updated automatically via the ON UPDATE CASCADE foreign key
    constraint already in place (migration V1753457861).

Changes

backend/src/services/segmentService.ts
In the update() method, when a leaf segment's slug changes, the linked insightsProject is looked up by segmentId and its
slug is updated (stripping the nonlf_ prefix, consistent with the creation flow).

services/libs/data-access-layer/src/collections/index.ts
Fixed a bug in createCollection where optional fields (logoUrl, imageUrl, color) were not defaulted to null, causing a
pg-promise error when callers omitted them.


Note

Medium Risk
Touches slug update flows across segments and insights projects and adds direct SQL updates to securityInsights* tables; mistakes could cause stale analytics or unintended slug propagation. Scope is limited to update paths and guarded by conditions.

Overview
Automatically syncs insightsProjects.slug when a leaf segment (subproject) slug is updated, normalizing away the nonlf_ prefix before updating the linked insights project.

Makes insights project updates safer by only syncing repositoryGroups when the field is explicitly provided, and when a project slug changes, explicitly bumps updatedAt on securityInsightsEvaluationSuites, securityInsightsEvaluations, and securityInsightsEvaluationAssessments so downstream ingestion (Tinybird) detects the cascaded slug update.

Written by Cursor Bugbot for commit 2dc232a. This will update automatically on new commits. Configure here.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@ulemons ulemons changed the title feat: update insightsProject slug feat: update insightsProject slug (CM-1043) Mar 16, 2026
@ulemons ulemons marked this pull request as ready for review March 16, 2026 16:03
Copilot AI review requested due to automatic review settings March 16, 2026 16:03
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR ensures that when a leaf segment (sub-project) slug is updated, the corresponding insightsProjects.slug stays in sync, relying on existing FK ON UPDATE CASCADE behavior for related securityInsights* tables. It also aims to address a DAL bug when creating collections with omitted optional fields.

Changes:

  • Sync insightsProjects.slug when a sub-project segment’s slug changes (normalizing by stripping nonlf_).
  • Rely on existing ON UPDATE CASCADE to propagate insightsProjectSlug changes to securityInsights* tables.
  • Fix createCollection to default optional fields (logoUrl, imageUrl, color) to null when omitted.

Reviewed changes

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

File Description
backend/src/services/segmentService.ts Updates linked insights project slug when a sub-project segment slug changes.
services/libs/data-access-layer/src/collections/index.ts Adjusts collection creation to avoid errors when optional fields are omitted.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Copy link
Contributor

@joanagmaia joanagmaia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

ulemons added 3 commits March 18, 2026 13:31
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
@ulemons ulemons force-pushed the feat/update-insights-slug branch from b62af5f to 2dc232a Compare March 18, 2026 12:31
@ulemons ulemons merged commit f0af002 into main Mar 18, 2026
10 checks passed
@ulemons ulemons deleted the feat/update-insights-slug branch March 18, 2026 12:43
skwowet pushed a commit that referenced this pull request Mar 18, 2026
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
skwowet pushed a commit that referenced this pull request Mar 18, 2026
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants